﻿CreateTray:
Menu, Tray, Icon, %A_ScriptDir%\workflow_icon.png
menu, Tray, DeleteAll
Menu, Tray, NoStandard
;menu, Tray, UseErrorLevel
Menu, Tray, tip, %_AppName%`n版本:%Version%
menu, Tray, add, %_AppName% %Version% ,About
Menu, Tray, disable, %_AppName% %Version% 
menu, Tray, add
; menu, Tray, add, %_StartUp%(&S),StartUp


;if StartUp

;menu, Tray, check, %_StartUp%
;menu, Tray, add, %_UpdatPlugins% &U, <UpdatPlugins>
;menu, tray, disable, %_Author%
; Menu, Tray, add, %_HotKeyManagement%(&H), <VimDConfig_KeymapEdit>
; Menu, Tray, add, 功能管理, <VimDConfig_function>
; Menu, Tray, Add, %_Config%(&C), <VimDConfig_EditConfig>
; Menu, Tray, Add, %_Path%(&P), <EditConfig>
;Menu, Tray, Add,
;Menu, Tray, Add, 编辑Custom &C, <VimDConfig_EditCustom>
; Menu, Tray, Add,
;Menu, Tray, Add, (&H) %_Help%, <VIMD_Help>

;menu, Tray, add, (&U) %_Updater% , <Updater>
Menu, LangSet, add, 中文,中文
Menu, LangSet, add, English,English
Menu, tray, add, %_Language%, :LangSet


Menu, aboutMe, add, %_Help%(&H), <VIMD_Help>
; Menu, aboutMe, add, %_Update%(&U), <VIMD_Update>
Menu, aboutMe, add, %_Web%(&W), <VIMD_WorkFlowWeb>
Menu, tray, add, %_aboutMe%(&L), :aboutMe
; Menu, aboutMe, add, (&U) %_Update%, Check_Update

; Menu, aboutMe, add, 系统状态监测(&B), 系统状态监测
; Menu, aboutMe, add, %_AppName%添加为系统变量(&B), <VIMD_EnvSystem>


Menu, OptionSet, add, 将 %_AppName% 目录添加为系统变量(&B), <VIMD_EnvSystem>
Menu, OptionSet, add, %_BackupRestore%, <VIMD_BackupRestore>

Menu, tray, add, %_Option%, :OptionSet

Menu, Tray, Add, %_Pause%(&P), <Pause>
Menu, Tray, Add, %_Restart%(&R), <Reload>
Menu, Tray, Add, %_Exit%(&X), Exit
Menu, Tray, Click, 1

VimdRun()

if (FirstParameter!="silent")
{
    Gui,welcome: +LastFound +AlwaysOnTop -Caption +ToolWindow
    Gui,welcome: Color, %BGColor%
    Gui,welcome: Font,c%BGTxtColor% s8 wbold q5,Segoe UI
    Gui,welcome: Add, Text, ,%_Welcome% 
    Gui,welcome: Font,c%BGTxtColor% s50 wbold q5,Segoe UI
    Gui,welcome: Add, Text, ,%_AppName%
    Gui,welcome: Font,c%BGTxtColor% s8 wbold q5,Segoe UI
    Gui,welcome: Add, Text, ,%_Authors%   %Update%   V:%Version%                                                      
    Gui,welcome: Font,c%BGTxtColor% s8 wbold q5,Segoe UI
    Gui,welcome: Show,AutoSize Center NoActivate
    WinSet, Transparent,200
    sleep %SleepTime%
    Gui,welcome: Hide
}
return

Author:
About:
License:
Return

中文:
IniWrite, CN, config.ini, config, Language
Reload
Return

English:
IniWrite, EN, config.ini, config, Language
Reload
Return

<Pause>:
	Pause
return


系统状态监测:
if 系统状态监测
{
    系统状态监测=0

}
else
{
    系统状态监测=1
}
Return

;开机启动

Startup:

if Startup
{
    RegDelete, HKLM\Software\Microsoft\Windows\CurrentVersion\Run, WorkFlow
    StartUp=0
    menu,tray,uncheck,%_StartUp%
}
else
{
    RegWrite, REG_SZ, HKLM\Software\Microsoft\Windows\CurrentVersion\Run, WorkFlow, %A_ScriptFullPath%
    StartUp=1
    menu,tray,check,%_StartUp%
}
Return

<VIMD_EnvSystem>:
{
    Gui, Color, 37474F
    Gui -Caption
    Gui, Font, s32,Microsoft YaHei
	  Gui, +AlwaysOnTop +Disabled -SysMenu +Owner 
	  Gui, Add, Text,cffffff,设置%_AppName%为系统变量
	  Gui, Show, xCenter yCenter, 状态, NoActivate,
	  sleep, 1200
	  Gui, Destroy
    
    gotoSetEvn=%A_ScriptDir%\Env_SystemAdd.ahk
    FileDelete, %gotoSetEvn% ;先删除文件
    FileAppend,  ; 这里需要逗号.
    (
#Include %A_ScriptDir%\lib\Environment.ahk
Env_SystemAdd("%_AppName%","%A_ScriptDir%")
return
ExitApp
    ), %A_ScriptDir%\Env_SystemAdd.ahk,UTF-8
    sleep 500
    run, %A_ScriptDir%\Env_SystemAdd.ahk
    sleep 2000
    FileDelete, %A_ScriptDir%\Env_SystemAdd.ahk
    return
}

; 用户自定义配置
<EditConfig>:
    run , %A_ScriptDir%\Editor.ahk
return

<VIMD_WorkFlowWeb>:
Run, https://github.com/lingchuanbo/WorkFlow
return

<VIMD_Help>:
Run, https://www.notion.so/WorkFlow-5473b03e9dad41ecb79bc3c5b5ac2913
return



<VIMD_BackupRestore>:
; MsgBox, 4,, 如果您更新过程序 请选择是? (press Yes or No)
; IfMsgBox Yes
;     if FileExist("%A_ScriptDir%\vimd_备份_还原.ini")
;         {
Gui,Backup: Add, Button, xCenter y20 w80 h50 gBackup, 备份
Gui,Backup: Add, Button, x100 y20 w80 h50 gBackupRestore, 还原
Gui,Backup: Show, xCenter w180 h100, %_AppName%
return

GuiClose:
ExitApp

Backup:
Gui,Backup: Hide
ToolTipFont("s12","Microsoft YaHei")
ToolTipColor("053445", "40A1EC")
ToolTip, 正在执行备份！
sleep 100
SetTimer, RemoveToolTip, -1000
FileCopy, %A_ScriptDir%\config.ini, %A_ScriptDir%\vimd_备份_还原.ini ,1
return

BackupRestore:
Gui,Backup: Hide
ToolTipFont("s12","Microsoft YaHei")
ToolTipColor("053445", "40A1EC")
ToolTip, 正在执行还原操作！
sleep 100
SetTimer, RemoveToolTip, -1000
FileCopy, %A_ScriptDir%\vimd_备份_还原.ini, %A_ScriptDir%\config.ini ,1
sleep 500
ToolTip, 重启中...
SetTimer, RemoveToolTip, -1000
FileRecycle, %A_ScriptDir%\vimd_备份_还原.ini
sleep 500
Reload
Return

Exit:
FileRemoveDir,%ProgramFilesDir%,1
MsgBox,0x40134,%_AppName%,%_ConfirmExit%
IfMsgBox, Yes
Exitapp
Return

; ~LButton:: 
; 	ToolTip
; return